#!/usr/bin/env python

import sys
import hmac
import hashlib
import time

# Example API credentials
client_id = 'dead'
client_key = 'Nf65RsEPJrrwXnuEFmtPoikF5sd1mASqK107p9duH4VtAjJfQimlKi2G7TuMdXAN'

# The 'hello' service ID and version
service_id = 'beef'
service_version = 'f00d'

# Our service endpoint and params
endpoint_and_params = 'hello?msg=GOSPL'

# Current time GMT
ts = time.strftime('%Y%m%d%H%M%S', time.gmtime())

# Sign for GET
uri = '%s-%s-%s-%s' % (client_id, service_id, service_version, ts)
data = 'GET-%s' % uri
signature = hmac.new(client_key, data, hashlib.sha1).hexdigest()

# Print signed service URL
print 'http://localhost/%s-%s/%s' % (signature, uri, endpoint_and_params) 
